package com.rs.game;

import com.rs.game.player.Player;

public final class Hit {
	
	public static enum HitLook {
		Miss_Hit(-1,0),
		Hit(1,-1),
		Melee_Hit(1,1),
		Range_Hit(1,2),
		Mage_Hit(1,3),
		Reflect_Hit(1,5),
		Absorve_Hit(4,4);
		private int mark;
		private int icon;
		
		private HitLook(int mark, int icon) {
			this.mark = mark;
			this.icon = icon;
		}
		
		public int getMark() {
			return mark;
		}
		
		public int getIcon() {
			return icon;
		}
		
		
	}
	private Entity source;
	private HitLook look;
	private int damage;
	private boolean critical;
	
	public void setCriticalMark() {
		critical = true;
	}
	
	public Hit(Entity source, int damage, HitLook look) {
		this.source = source;
		this.damage = damage;
		this.look = look;
	}
	
	public int getMark(Player player, Entity victm) {
		//melee,range,mage hit
		if(damage == 0 && (look.getIcon() == 1 || look.getIcon() == 2 || look.getIcon() == 3))
			return HitLook.Miss_Hit.getMark();
		return (critical ? 0 : look.getMark()) + (player == victm || player == source ? 0 : 5);
	}
	
	
	public int getIcon() {
		//normal hit/critical
		if(damage == 0 && (look.getMark() == 1 || look.getMark() == 2))
			return HitLook.Miss_Hit.getIcon();
		return look.getIcon();
	}
	
	public HitLook getLook() {
		return look;
	}

	public int getDamage() {
		return damage;
	}
	
	public void setDamage(int damage) {
		this.damage = damage;
	}

	public Entity getSource() {
		return source;
	}

	public void setSource(Entity source) {
		this.source = source;
	}
	

}
